package com.ie.sevice.admin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ie.common.http.ResponseResult;
import com.ie.entity.GoodsEntity;
import com.ie.entity.OrdersEntity;
import com.ie.entity.getA110rdersEntity;
import com.ie.mapper.admin.getA110redersMapper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class getA110rdersServiceImpl extends ServiceImpl<getA110redersMapper, getA110rdersEntity> implements getA110rdersService {
    private getA110redersMapper getA110rdersMapper;
    public getA110rdersServiceImpl(getA110redersMapper getA110rdersMapper) {
        this.getA110rdersMapper = getA110rdersMapper;
    }
    @Override
    public ResponseResult<Map<String,Object>> getA110rders(getA110rdersEntity getA110rdersEntity) {
        Integer pagenum = getA110rdersEntity.getCurrentPage();
        if(pagenum == null || pagenum < 1) {
            getA110rdersEntity.setCurrentPage(1);
        }
        IPage<GoodsEntity> iPage = new Page<>(getA110rdersEntity.getCurrentPage(),5);
        LambdaQueryWrapper<GoodsEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        Integer goodstypeId = getA110rdersEntity.getgetA110rderstypeId();
        String gname = getA110rdersEntity.getGname();
        if (goodstypeId != null&&goodstypeId>0) {
            lambdaQueryWrapper.eq(GoodsEntity::getGoodstypeId, goodstypeId);
        }
        if(gname!=null&&!gname.isEmpty()){
            lambdaQueryWrapper.like(GoodsEntity::getGname, gname);
        }
        IPage<GoodsEntity> page = getA110rdersMapper.iPageGoods(iPage, lambdaQueryWrapper);
        HashMap<String, Object> myres = new HashMap<>();
        myres.put("allOrders", page.getRecords());
        myres.put("totalPage", page.getPages());
        return ResponseResult.getSuccessResult(myres);
    }

    @Override
    public ResponseResult<Map<String, Object>> getA110rders(OrdersEntity getA110rdersEntity) {
        return null;
    }

    @Override
    public ResponseResult<Map<String, Object>> getamount(OrdersEntity ordersEntity) {
        return null;
    }

    @Override
    public ResponseResult<Map<String, Object>> getstatus(OrdersEntity ordersEntity) {
        return null;
    }

    @Override
    public ResponseResult<Map<String, Object>> getbusertableId(OrdersEntity ordersEntity) {
        return null;
    }
}
